package com.qymerge.manage.base.service.impl;

import com.qymerge.manage.base.dao.IBDMSaleLinesDao;
import com.qymerge.manage.base.ro.BDMSaleLinesRO;
import com.qymerge.manage.base.service.IBDMSaleLinesService;
import com.qymerge.manage.base.service.IBDMVoucherService;
import com.qymerge.manage.core.bean.DataTableRO;
import com.qymerge.manage.core.bean.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *<p>Title: BDMSaleLinesServiceImpl</p>
 *<p>Description: </p>
 *
 *@Author cong.zhang
 *@Version 1.0.0
 *@Date 2020/12/19
 *@Time 17:53
 */
@Service
public class BDMSaleLinesServiceImpl implements IBDMSaleLinesService {

    @Autowired
    private IBDMSaleLinesDao saleLinesDao;

    /**
     * 用户管理-查询
     *
     * @param ro
     * @param pageRequest
     * @return
     */
    @Override
    public DataTableRO list(BDMSaleLinesRO ro, PageRequest pageRequest) {
        List list = saleLinesDao.list(ro, pageRequest);
        DataTableRO dataTableRO = new DataTableRO();
        int allCount = saleLinesDao.total(ro);
        int pageSize = pageRequest.getSize();
        dataTableRO.setAll_count(allCount);
        dataTableRO.setList(list);
        dataTableRO.setCurrent_page(pageRequest.getPage());
        dataTableRO.setPage_size(pageSize);
        int allPage = (allCount % pageSize == 0 ? allCount / pageSize : allCount / pageSize + 1);
        dataTableRO.setAll_page(allPage);
        return dataTableRO;
    }

    /**
     * 详情
     *
     * @param id
     * @return
     */
    @Override
    public BDMSaleLinesRO detail(Long id) {
        return saleLinesDao.findOne(id);
    }


}
